package com.lxj.xpopup.util;


import android.Manifest;
import android.Manifest.permission;
import android.annotation.SuppressLint;

import androidx.annotation.StringDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * Description: copy from https://github.com/Blankj/AndroidUtilCode
 * Create by dance, at 2019/4/1
 */
@SuppressLint("InlinedApi")
public final class PermissionConstants {

    public static final String CAMERA     = Manifest.permission_group.CAMERA;
    public static final String MICROPHONE = Manifest.permission_group.MICROPHONE;
    public static final String STORAGE    = Manifest.permission_group.STORAGE;

    private static final String[] GROUP_CAMERA        = {
            permission.CAMERA
    };
    private static final String[] GROUP_MICROPHONE    = {
            permission.RECORD_AUDIO
    };
    private static final String[] GROUP_STORAGE       = {
            permission.READ_EXTERNAL_STORAGE, permission.WRITE_EXTERNAL_STORAGE
    };

    @StringDef({CAMERA, MICROPHONE, STORAGE,})
    @Retention(RetentionPolicy.SOURCE)
    public @interface Permission {
    }

    public static String[] getPermissions(@Permission final String permission) {
        switch (permission) {
            case CAMERA:
                return GROUP_CAMERA;
            case MICROPHONE:
                return GROUP_MICROPHONE;
            case STORAGE:
                return GROUP_STORAGE;
        }
        return new String[]{permission};
    }
}